﻿using System;
using System.IO;
using log4net;
using log4net.Config;

namespace Log4Wrapper
{
    /// <summary>
    ///     LogHelper的摘要说明。
    /// </summary>
    public class ZLLogger
    {
        public static readonly ILog loginfo = LogManager.GetLogger("loginfo");
        public static readonly ILog logerror = LogManager.GetLogger("logerror");

        private ZLLogger()
        {
        }

        public static void SetConfig()
        {
            DOMConfigurator.Configure();
        }

        public static void SetConfig(FileInfo configFile)
        {
            DOMConfigurator.Configure(configFile);
        }

        public static void WriteLog(string info)
        {
            if (loginfo.IsInfoEnabled)
            {
                loginfo.Info(info);
            }
        }

        public static void WriteLog(string info, Exception se)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(info, se);
            }
        }

        public static void WriteLog(Exception se)
        {
            if (logerror.IsErrorEnabled)
            {
                logerror.Error(se);
            }
        }
    }
}